<?php
include("../share/config.php");

$name = $_POST["name"];
$id = $_POST["stid"];
$pw = $_POST["pw"];
$who = $_POST["who"];

$sql="SELECT * from user where student_id = '$id'";
$search = mysqli_query($conn,$sql);
$count=mysqli_num_rows($search);
if ($count>0)
{
	echo "<a href='../pages/signup.php'>此学号已被注册，如有问题请咨询管理员！</a>";
}
else
{
	if($who == "0"){
		$sq = $_POST["squestion"];
		$sele = $_POST["sele"];
		$sql = "INSERT INTO `Lib`.`user`(user_name,password,student_id,verify,type,point,sq,sq_ans) VALUES('{$name}','{$pw}','{$id}','0','{$who}','300','{$sele}','{$sq}')";
		$insert = mysqli_query($conn,$sql);  
		mysqli_close($conn);
		Header("Location:../pages/login.php");
		}
	else{
		$code = $_POST["code"];
		if($code=="2000"){
			$sql = "INSERT INTO `Lib`.`user`(user_name,password,student_id,verify,type) VALUES('{$name}','{$pw}','{$id}','1','1')";
			$insert = mysqli_query($conn,$sql);  
			mysqli_close($conn);
			Header("Location:../pages/login.php");
		}
		else{
			echo "<a href='../pages/signup.php'>验证码错误，如有问题请咨询管理员！</a>";
		}
	}
}
?>
 